package com.jwthhealth_pub.wristband.view.widget;

import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.jwthhealth_pub.R;

/**
 * Created by yang on 2017/12/26.
 */

public class MyRingView extends RelativeLayout {
    private Context mContext;
    private ImageView iv_circle;
    private ImageView iv_solid;
    public MyRingView(Context context) {
        super(context);
        initView(context);
    }
    public MyRingView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }
    public MyRingView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView(context);
    }
    private void initView(Context context) {
        mContext = context;
        inflate(mContext, R.layout.activity_myringview_layout, this);
        iv_circle = (ImageView) findViewById(R.id.iv_circle);
        iv_solid = (ImageView) findViewById(R.id.iv_solid);
    }
    /**
     * @param color 颜色
     * @param isSolid  内部是否填充
     */
    public void setStyle(int color, boolean isSolid) {
        ((GradientDrawable) iv_circle.getBackground()).setStroke(2, color);//圆环的颜色
        if (isSolid) {
            ((GradientDrawable) iv_solid.getBackground()).setColor(color);//指定内部圆的背景色
            ((GradientDrawable) iv_solid.getBackground()).setStroke(30, color);//内部圆无描边，必须显示设为0
        } else {
            ((GradientDrawable) iv_solid.getBackground()).setColor(getResources().getColor(R.color.primarycolor));//内部圆的背景是白色的
            ((GradientDrawable) iv_solid.getBackground()).setStroke(30, color);//内部圆有描边
        }
    }
}